package cn.e3mall.message;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;

import org.springframework.jms.core.MessageCreator;

public class ItemMessageCreator implements MessageCreator{
	//发送的消息
	private String text;
	
	public ItemMessageCreator(String text) {
		this.text = text;
	}

	@Override
	public Message createMessage(Session session) throws JMSException {
		
		Message message = null;
		
		if(text == null) throw new RuntimeException("消息不能为空");
		
			//创建消息对象
			message = session.createTextMessage(text);
			
			//返回消息对象
			return message;
			
	}

}
